package com.tywj.buscustomerapp.view.item;

import android.content.Intent;
import android.support.annotation.NonNull;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.tywj.buscustomerapp.Config;
import com.tywj.buscustomerapp.R;
import com.tywj.buscustomerapp.model.bean.ProblemBean;
import com.tywj.buscustomerapp.utils.myadapter.item.AdapterItem;
import com.tywj.buscustomerapp.view.activity.ImageActivity;

public class ActItme implements AdapterItem<ProblemBean> {
    private ImageView img;
    private TextView title;
    private LinearLayout content;
    @Override
    public int getLayoutResId() {
        return R.layout.item_activity_layout;
    }

    @Override
    public void bindViews(@NonNull View root) {
        img = root.findViewById(R.id.image);
        title = root.findViewById(R.id.title);
        content = root.findViewById(R.id.content);
    }

    @Override
    public void setViews() {

    }

    @Override
    public void handleData(final ProblemBean problemBean, int position) {
        Glide.with(this.img.getContext())
                .load(Config.IMGURL+"/manage/huodong/"+problemBean.getSmImg())
                .into(img);
        title.setText(problemBean.getQuestion());
        content.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (problemBean.getSmImg()!=null && !problemBean.getSmImg().equals("")) {
                    Intent intent = new Intent(v.getContext(), ImageActivity.class);
                    intent.putExtra("url", problemBean.getAnswer());
                    intent.putExtra("imgurl", Config.IMGURL + "/manage/huodong/" + problemBean.getImg());
                    v.getContext().startActivity(intent);
                }
            }
        });
    }
}
